<?php
/**
 * Created by PhpStorm.
 * User: 18048
 * Date: 2018/5/14
 * Time: 14:35
 */
$client = new swoole_client(SWOOLE_SOCK_TCP,SWOOLE_SOCK_ASYNC);

$client->on("connect",function(swoole_client $cli){
    $cli->send("GET / HTTP/1.1\r\n\r\n");
});

$client->on("receive",function(swoole_client $cli,$data){
    echo "Receive:$data";
    $cli->send(str_repeat('A',100)."\n");
    sleep(1);
});

$client->on('error',function(swoole_client $cli){
    echo "error\n";
});

$client->on("close",function(swoole_client $cli){
   echo "Connection close\n";
});